package com.test.constructor;

public class Student {
    String name;
    int age;
    char sex;

    //构造器是一种方法，方法名和类名相同，没有返回值
    //1.无参数构造器
    public Student() {
        System.out.println("===无参数构造器执行了===");
    }

    //2.有参数构造器
    public Student(String n) {
        System.out.println("===有参数构造器执行了===");
    }
    //构造器重载
    public Student(String n, int a) {
        System.out.println("===有参数构造器-重载执行了===");
    }

    public Student(String name, int age, char sex) {//有参构造器
        this.name = name;
        this.age = age;
        this.sex = sex;
    }
}
